<template>
  <div>
    <input v-focus type="text" ref="ipt" placeholder="搜索框" v-if="showIpt" />
    <button @click="handleSearch">点击搜索</button>

    <div v-color="color">传智</div>
    <button @click="color = 'red'">点击改变颜色</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showIpt: false,
      color:'blue',
    }
  },
  // directives: {
  //   focus: {
  //     inserted(el) {
  //       el.focus()
  //     },
  //   },
  // },
  methods: {
    handleSearch() {
      this.showIpt = true
    },
  },
}
</script>

<style></style>